Skip to content

Conversation

@aliamadi
Copy link
Contributor

@aliamadi aliamadi commented Jan 5, 2026

Summary

The Flowbite React CLI could crash at runtime when a custom configuration
was used (e.g. dark: false). This triggers the CLI to evaluate the
<ThemeInit /> warning logic, where an array method was incorrectly called
on a MapIterator.

Fix

  • Safely evaluate checkedMap values without calling array methods on a MapIterator
  • Only run the warning logic after at least one file has been checked
this.checkedMap.size > 0 &&
!Array.from(this.checkedMap.values()).some(Boolean)

Verification

Built the package and tested it in a Next.js project where the CLI previously
crashed with dark: false. The issue no longer occurs.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed a CLI crash and improved warning display so warnings appear only when appropriate.
  • Documentation

    • Added a changelog entry and a small patch version update for a UI dependency.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: c62e967

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
flowbite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jan 5, 2026

@aliamadi is attempting to deploy a commit to the Bergside Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

Replaced a simple truth-check in the init logger's showWarning getter with an explicit iteration over checkedMap that sets a flag if any value is true and returns the negation of that flag; no public API/signature changes.

Changes

Cohort / File(s) Change Summary
Init logger logic
packages/ui/src/cli/utils/create-init-logger.ts
Rewrote showWarning getter to iterate checkedMap values and determine the warning flag explicitly instead of using a direct truthy check.
Changeset
.changeset/twelve-dogs-refuse.md
Added changeset noting a fix: "Fix CLI crash by safely iterating over Map values in init logger." and bumped dependency patch.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

:bug: bug

Suggested reviewers

  • rluders

Poem

🐰 I hopped through code with care and cheer,
I checked each flag both far and near,
No crash remains where maps once tripped,
The CLI hops on—no warnings slipped. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title specifically mentions the CLI crash scenario and the custom config parameter that triggers it, clearly summarizing the main bug fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SutuSebastian
Copy link
Collaborator

Please provide full reproduction steps, because the "could crash" is very vague and non technical, also I never experienced this locally or in any React based framework or technology out of all specified in the "Integrations".

It either crashes or not under certain situations, which I would like to test myself before working on this.

@aliamadi
Copy link
Contributor Author

aliamadi commented Jan 6, 2026

Please provide full reproduction steps, because the "could crash" is very vague and non technical, also I never experienced this locally or in any React based framework or technology out of all specified in the "Integrations".

It either crashes or not under certain situations, which I would like to test myself before working on this.

Thanks for checking this. Here are the exact reproduction steps:

Environment:

  • OS: WSL (Ubuntu-24.04)
  • Node: v20.19.5
  • Package manager: pnpm

Steps:

  1. Run: npx create-flowbite-react@latest -t nextjs
  2. Enter the generated project directory
  3. Run: pnpm install
  4. Edit .flowbite-react/config.json and set:
    {
    "dark": false
    }
  5. Run: pnpm dev (or pnpm build)

Result:

  • The app crashes with the following error:

    TypeError: this.checkedMap.values(...).find is not a function
    at get showWarning [as showWarning]
    (flowbite-react/dist/cli/utils/create-init-logger.cjs)

Expected result:

  • The app should run correctly, same as when "dark" is set to true.

Additional notes:

  • This issue consistently reproduces on Node v20.19.5.
  • Using newer Node versions (without changing the code) does not reproduce the crash.
  • With "dark": true, everything works as expected.

I've attached a screenshot of the full error output for additional context.
Screenshot 2026-01-06 123827

@SutuSebastian
Copy link
Collaborator

Thanks for the extra info. This is exactly what I wanted to highlight out of this, the node version has something to do with it and I need to dig into how it resolves the JS part in that exact version.

@SutuSebastian SutuSebastian linked an issue Jan 6, 2026 that may be closed by this pull request
2 tasks
@SutuSebastian
Copy link
Collaborator

I see it now, can confirm the issue.
Since Bun has built-in map iterator helpers, but can't guarantee that all the rest of the JS runtimes have it, it's safer to stick to a for...of loop instead, since it's much more efficient.

eg:

get showWarning() {
  let hasChecked = false;

  for (const value of this.checkedMap.values()) {
    if (value) {
      hasChecked = true;
      break;
    }
  }

  return !hasChecked;
}
  1. please replace ur change with the above snippet
  2. make sure to create a changeset file by running bun changeset at the root level, and select flowbite-react package and bump it as a patch

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/ui/src/cli/utils/create-init-logger.ts (1)

23-32: Consider renaming hasChecked for clarity and verify if size guard is needed.

The variable name hasChecked is misleading—it sounds like "has checked any files" but actually means "found a ThemeInit component." Consider renaming to foundThemeInit or hasThemeInit for clarity.

Additionally, the PR description mentions adding a guard expression (this.checkedMap.size > 0 && ...) to only evaluate the warning logic after at least one file has been checked. The current implementation will return true (show warning) when checkedMap is empty, which means the warning displays even if no files have been processed yet. Was omitting the size check intentional based on reviewer feedback, or should it be added?

🔎 Suggested improvements

Option 1: Clearer naming only

-      let hasChecked = false;
+      let foundThemeInit = false;

       for (const value of this.checkedMap.values()) {
         if (value) {
-          hasChecked = true;
+          foundThemeInit = true;
           break;
         }
       }

-      return !hasChecked;
+      return !foundThemeInit;

Option 2: With size guard (as mentioned in PR description)

-      let hasChecked = false;
+      if (this.checkedMap.size === 0) {
+        return false;
+      }
+
+      let foundThemeInit = false;

       for (const value of this.checkedMap.values()) {
         if (value) {
-          hasChecked = true;
+          foundThemeInit = true;
           break;
         }
       }

-      return !hasChecked;
+      return !foundThemeInit;
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7c80a5 and c62e967.

📒 Files selected for processing (2)
  • .changeset/twelve-dogs-refuse.md
  • packages/ui/src/cli/utils/create-init-logger.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: SutuSebastian
Repo: themesberg/flowbite-react PR: 1621
File: packages/ui/src/cli/commands/install.ts:46-48
Timestamp: 2025-09-01T10:45:00.071Z
Learning: In the flowbite-react CLI install command, the maintainer prefers a simple Windows support implementation that appends .cmd to all commands on win32, rather than a more defensive approach, because they know the command will only be package managers from the resolveCommand function.
📚 Learning: 2025-09-01T10:45:00.071Z
Learnt from: SutuSebastian
Repo: themesberg/flowbite-react PR: 1621
File: packages/ui/src/cli/commands/install.ts:46-48
Timestamp: 2025-09-01T10:45:00.071Z
Learning: In the flowbite-react CLI install command, the maintainer prefers a simple Windows support implementation that appends .cmd to all commands on win32, rather than a more defensive approach, because they know the command will only be package managers from the resolveCommand function.

Applied to files:

  • .changeset/twelve-dogs-refuse.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: 🧰 Build
🔇 Additional comments (1)
.changeset/twelve-dogs-refuse.md (1)

1-5: LGTM!

The changeset format is correct, the patch bump is appropriate for this bug fix, and the description clearly summarizes the change.

@aliamadi
Copy link
Contributor Author

aliamadi commented Jan 6, 2026

I see it now, can confirm the issue. Since Bun has built-in map iterator helpers, but can't guarantee that all the rest of the JS runtimes have it, it's safer to stick to a for...of loop instead, since it's much more efficient.

eg:

get showWarning() {
  let hasChecked = false;

  for (const value of this.checkedMap.values()) {
    if (value) {
      hasChecked = true;
      break;
    }
  }

  return !hasChecked;
}
  1. please replace ur change with the above snippet
  2. make sure to create a changeset file by running bun changeset at the root level, and select flowbite-react package and bump it as a patch

Thanks! I replaced the logic with the suggested for...of loop
and added a patch changeset for flowbite-react as requested.

Copy link
Collaborator

@SutuSebastian SutuSebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@SutuSebastian SutuSebastian merged commit 3e65ed2 into themesberg:main Jan 7, 2026
5 of 7 checks passed
@github-actions github-actions bot mentioned this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot generate file .flowbite-react/class-list.json when deploying on Vercel

2 participants